﻿
#region Using Directives.

using System;
using System.Drawing;

#endregion

namespace GDFlacTool.Common
{
    [Serializable]
    public abstract class Track
    {
        #region Fields.

        //private readonly string _trackFormat = string.Empty;
        //private read

        #endregion

        #region Constructors.

        protected Track()
        {
            BitsPerSample = string.Empty;
            Trackrename = null;
            Encoder = string.Empty;
            SampleRate = string.Empty;
            Time = string.Empty;
            FullPath = string.Empty;
            FilePath = string.Empty;
            FileName = string.Empty;
            Album = string.Empty;
            Artist = string.Empty;
            Albumartist = string.Empty;
            Title = string.Empty;
            Year = string.Empty;
            Genre = string.Empty;
            Comment = string.Empty;
            TrackNumber = string.Empty;
            DiscNumber = string.Empty;
            Catalog = string.Empty;
            Isrc = string.Empty;
            ReleaseType = string.Empty;
            Composer = string.Empty;
            Originalartist = string.Empty;
            Copyright = string.Empty;
            Url = string.Empty;
            EncodedBy = string.Empty;
            Mood = string.Empty;
            Rating = string.Empty;
            Quality = string.Empty;
            Bpm = string.Empty;
            Lyrics = string.Empty;
            Conductor = string.Empty;
            Lyricist = string.Empty;
            OriginalLyricist = string.Empty;
            Label = string.Empty;
            RemixedBy = string.Empty;
            RadioStationName = string.Empty;
            AudioFileUrl = string.Empty;
            AuthorUrl = string.Empty;
            AudioSourceUrl = string.Empty;
            RadioStationUrl = string.Empty;
            BuyCdUrl = string.Empty;
        }

        protected Track(string path)
        {
            BitsPerSample = string.Empty;
            Trackrename = null;
            Encoder = string.Empty;
            SampleRate = string.Empty;
            Time = string.Empty;
            FilePath = string.Empty;
            FileName = string.Empty;
            Album = string.Empty;
            Artist = string.Empty;
            Albumartist = string.Empty;
            Title = string.Empty;
            Year = string.Empty;
            Genre = string.Empty;
            Comment = string.Empty;
            TrackNumber = string.Empty;
            DiscNumber = string.Empty;
            Catalog = string.Empty;
            Isrc = string.Empty;
            ReleaseType = string.Empty;
            Composer = string.Empty;
            Originalartist = string.Empty;
            Copyright = string.Empty;
            Url = string.Empty;
            EncodedBy = string.Empty;
            Mood = string.Empty;
            Rating = string.Empty;
            Quality = string.Empty;
            Bpm = string.Empty;
            Lyrics = string.Empty;
            Conductor = string.Empty;
            Lyricist = string.Empty;
            OriginalLyricist = string.Empty;
            Label = string.Empty;
            RemixedBy = string.Empty;
            RadioStationName = string.Empty;
            AudioFileUrl = string.Empty;
            AuthorUrl = string.Empty;
            AudioSourceUrl = string.Empty;
            RadioStationUrl = string.Empty;
            BuyCdUrl = string.Empty;
            FullPath = path;
        }

        #endregion

        #region Properties.

        public string FullPath { get; set; }
        public string FilePath { get; set; }
        public string FileName { get; set; }
        public string Album { get; set; }
        public string Artist { get; set; }
        public string Albumartist { get; set; }
        public string Title { get; set; }
        public string Year { get; set; }
        public string Genre { get; set; }
        public string Comment { get; set; }
        public string TrackNumber { get; set; }
        public string DiscNumber { get; set; }
        public string Catalog { get; set; }
        public string Isrc { get; set; }
        public string ReleaseType { get; set; }
        public string Composer { get; set; }
        public string Originalartist { get; set; }
        public string Copyright { get; set; }
        public string Url { get; set; }
        public string EncodedBy { get; set; }
        public string Mood { get; set; }
        public string Rating { get; set; }
        public string Quality { get; set; }
        public string Bpm { get; set; }
        public bool Compilation { get; set; }
        public string Lyrics { get; set; }
        public string Conductor { get; set; }
        public string Lyricist { get; set; }
        public string OriginalLyricist { get; set; }
        public string Label { get; set; }
        public string RemixedBy { get; set; }
        public string RadioStationName { get; set; }
        public string AudioFileUrl { get; set; }
        public string AuthorUrl { get; set; }
        public string AudioSourceUrl { get; set; }
        public string RadioStationUrl { get; set; }
        public string BuyCdUrl { get; set; }
        public string Encoder { get; set; }

        public bool HasFileCoverArt
        {
            get { return ArtImage != null; }
        }
        
        public long Size { get; set; }
        public Image ArtImage { get; set; }
        public byte[] ArtByteArray { get; set; }
        public long ArtSize { get; set; }
        public string Time { get; set; }
        public int BitRate { get; set; }
        public int Channels { get; set; }
        public string SampleRate { get; set; }
        public long TimeTicks { get; set; }
        public string BitsPerSample { get; set; }


        public bool IsArtistChanged { get; set; }
        public bool IsYearChanged { get; set; }
        public bool IsAlbumChanged { get; set; }
        public bool IsTitleChanged { get; set; }
        public bool IsGenreChanged { get; set; }
        public bool IsCommentChanged { get; set; }
        public bool IsTrackNumberChanged { get; set; }
        public bool IsDiscNumberChanged { get; set; }
        public bool IsCatalogChanged { get; set; }
        public bool IsIsrcChanged { get; set; }
        public bool IsReleaseTypeChanged { get; set; }
        public bool IsAlbumArtistChanged { get; set; }
        public bool IsComposerChanged { get; set; }
        public bool IsOriginalArtistChanged { get; set; }
        public bool IsCopyrightChanged { get; set; }
        public bool IsUrlChanged { get; set; }
        public bool IsEncodedByChanged { get; set; }
        public bool IsMoodChanged { get; set; }
        public bool IsRatingChanged { get; set; }
        public bool IsQualityChanged { get; set; }
        public bool IsBpmChanged { get; set; }
        public bool IsCompilationChanged { get; set; }
        public bool IsCoverArtChanged { get; set; }
        public bool IsLyricsChanged { get; set; }
        public bool IsLyricistChanged { get; set; }
        public bool IsOriginalLyricistChanged { get; set; }
        public bool IsConductorChanged { get; set; }
        public bool IsLabelChanged { get; set; }
        public bool IsRemixedByChanged { get; set; }
        public bool IsRadioStationNameChanged { get; set; }
        public bool IsAudioFileUrlChanged { get; set; }
        public bool IsAudioSourceUrlChanged { get; set; }
        public bool IsAuthorUrlChanged { get; set; }
        public bool IsBuyCdUrlChanged { get; set; }
        public bool IsRadioStationUrlChanged { get; set; }

        public TrackRename Trackrename { get; set; }

        public string OldFileName
        {
            get { return Trackrename.OriginalFileName; }
        }

        public string OldPath
        {
            get { return Trackrename.OriginalPath; }
        }

        public string NewFileName
        {
            get { return Trackrename.RenamedFileName; }
        }

        public string NewPath
        {
            get { return Trackrename.RenamedPath; }
        }

        public bool IsTrackRenamed
        {
            get { return Trackrename != null; }
        }

        #endregion

        #region Virtual Methods.

        public virtual void ClearTags(){}

        public virtual bool RenameTrack(MaskHelperCollection masks, TrackRename trackRename)
        {
            return false;
        }

        public virtual void SaveFrontCoverArt(byte[] bytes){}

        public virtual void RemoveFrontCoverArt(){}

        public virtual void SetTag(params string[] tagtype){}

        public virtual void SetTag(string tagtype){}

        public virtual void SetTags(){}

        public virtual void ClearUndo(){}

        public virtual void UpdateAfterRename(){}

        public virtual bool IsEmpty { get; set; }

        public abstract string TrackFormat { get; }

        public abstract bool IsSupportedTag { get; }

        #endregion
    }
}
